package br.project.cdd.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import br.project.cdd.bean.TelasBean;

public class TelasDAO extends Conexao{

	public TelasDAO() throws ClassNotFoundException, SQLException {
		super();
	}
	
	public ArrayList<TelasBean> buscarTodasTelas()
	{
		ArrayList<TelasBean> listTelas = new ArrayList<TelasBean>();
		TelasBean bean = null;
		
		try
		{
			String sql = "SELECT ID_TELA, DSC_TELA FROM TELAS";
			Statement stmt = conexao.createStatement();
			ResultSet consulta = stmt.executeQuery(sql);
			
			while (consulta.next())
			{
				bean = new TelasBean();				
				bean.setId_tela(consulta.getInt(1));
				bean.setDsc_tela(consulta.getString(2));
				
				listTelas.add(bean);
			}
		}
		catch(SQLException sqlEx)
		{
			sqlEx.printStackTrace();
		}
		
		return listTelas;
	}
}
